Connecting to a Data Source Using a Connection String
If your application requires a connection string to connect to a data source, you must specify the data source name that tells the driver which section in the system information to use for the default connection information. Optionally, you may specify attribute=value pairs in the connection string to override the default values stored in the system information. These values are not written to the system information.
You can specify either long or short names in the connection string. The connection string has the form:
An example of a connection string for Sybase is:
Table 2-1 gives the long and short names for each attribute, as well as a description.
The defaults listed in the table are initial defaults that apply when no value is specified in either the connection string or in the data source definition in the system information. If you specified a value for the attribute when configuring the data source, that value is the default.
Table 2-1. Sybase Wire Protocol Connection String Attributes Attribute Description ApplicationName (APP) The name used by Sybase to identify your application. ApplicationUsingThreads (AUT) ApplicationUsingThreads={0 | 1}. Ensures that the driver works with multi-threaded applications.When set to 1 (the initial default), the driver is thread-safe.When using the driver with single-threaded applications, you can set this option to 0 to avoid additional processing required for ODBC thread-safety standards. ArraySize (AS) The number of rows the driver retrieves from the server for a fetch. This is not the number of rows given to the user. This increases performance by reducing network traffic.The initial default is 50 rows. Charset (CS) The name of a character set. This character set must be installed on the Sybase server. The default is the setting on the Sybase server. For this driver to support Unicode, this attribute must be set to UTF-8. Refer to the Sybase server documentation for a list of valid character set names. CursorCacheSize (CCS) The number of connections that the connection cache can hold. To set the connection cache, you must set the SelectMethod attribute to 1. Increasing the connection cache may increase performance of some applications but requires additional database resources.The initial default is 1 (one cursor). Database (DB) The name of the database to which you want to connect. DataSourceName (DSN) A string that identifies a single connection to a Sybase database. Examples include "Accounting" or "Sys10-Serv1." DefaultLongDataBuffLen (DLDBL) An integer value that specifies, in 1024-byte multiples, the maximum length of data fetched from a TEXT or IMAGE column. You will need to increase this value if the total size of any long data exceeds 1 MB.The default is 1024. DistributedTransaction
Model (DTM)
DistributedTransactionModel={XA Protocol | Native OLE}. Determines which model is used for distributed transaction support. The initial default is XA Protocol. EnableDescribe
Param (EDP) EnableDescribeParam={0 | 1}. Determines whether the ODBC API function SQLDescribeParam is enabled.When set to 0 (the initial default), SQLDescribeParam is disabled.When set to 1, SQLDescribeParam is enabled, which allows an application to describe parameters in SQL statements and in stored procedure calls. To use this option, OptimizePrepare must be set to 0 or 1, and the SQL statement must not include long parameters. This attribute should be set to 1 when using Microsoft Remote Data Objects (RDO) to access data. EnableQuoted
Identifiers (EQI) EnableQuotedIdentifiers={0 | 1}. Enables quoted identifiers.When set to 0 (the initial default), quoted identifiers are disabled.When set to 1, quoted identifiers are enabled. FailoverNetworkAddress (FNA) Specifies the address of the High Availability (HA) Failover server to be used in the event of a connection loss. The driver detects the dropped connection and automatically reconnects to the HA Failover server specified by this attribute. This attribute is valid only for Sybase version 12 or higher servers that have the High Availability Failover feature enabled.See the previous description of the Network Address attribute for an explanation of valid values. Interfaces File (IF) Specifies the path name of the Interfaces file. If you do not specify a value for this attribute, but specify a value for the Interfaces File Server Name attribute, the driver looks for the path name of the Interfaces file in the Registry under HKEY_LOCAL_MACHINE\SOFTWARE\DataDirect\InterfacesFile. If this Registry value is empty, then the driver attempts to open the SQL.INI file found in the same directory as the driver and use it as the Interfaces file. Interfaces File Server Name (IFSN) Specifies the name of the section in the Interfaces file that contains the network connection information for the Sybase server you want to access. The section name typically is the host name of the server that contains the Sybase Server you want to access. InitializationString (IS) InitializationString={Sybase set commands;...}. Supports the execution of Sybase commands at connect time. Multiple commands must be separated by semicolons. Language (LANG) The national language. This language must be installed on the Sybase server.The initial default is English. LogonID (UID) The default logon ID used to connect to your Sybase database. This ID is case-sensitive. A logon ID is required only if security is enabled on your database. If so, contact your system administrator to get your logon ID. NetworkAddress (NA) The network address depends on which network protocol is chosen under Network Library Name and on the Sybase server. If you have chosen Winsock, specify an IP address as follows: "servernameorIP address, port number". For example, if your network supports named servers, you may specify an address such as "Sybaseserver, 5000". You may also specify the IP address directly such as "199.226.224.34, 5000".If you have chosen NamedPipes as the network protocol, you must specify the pipe address of the server. For example, "\\machine1\sybase\pipe\query". NetworkLibraryName (NLN)
NetworkLibraryName={Winsock | NamedPipes}. The name of the network library. This specifies which network protocol to use.The initial default is Winsock. OptimizePrepare (OP) OptimizePrepare={0 | 1 | 2 | 3}. Determines whether stored procedures are created on the server for calls to SQLPrepare.When set to 0, stored procedures are created for every call to SQLPrepare. This setting can result in decreased performance when processing statements that do not contain parameters.When set to 1 (the initial default), the driver creates stored procedures only if the statement contains parameters. Otherwise, the statement is cached and run directly at the time of SQLExecute.When set to 2, stored procedures are never created. The driver caches the statement, executes it directly at the time of SQLExecute, and reports any syntax or similar errors at the time of SQLExecute.When set to 3, stored procedures are never created. This is identical to value 2 except that any syntax or similar errors are returned at the time of SQLPrepare instead of SQLExecute. Use this setting only if you must have syntax errors reported at the time of SQLPrepare. PacketSize (PS) PacketSize={-1 | 0 | x}. Determines the number of bytes per network packet transferred from the database server to the client. The correct setting of this attribute can improve performance.When set to -1, the driver computes the maximum allowable packet size on the first connect to the data source and saves the value in the system information.When set to 0 (the initial default), the driver uses the default packet size as specified in the Sybase server configuration.When set to x, an integer from 1 to 1024, the driver uses a packet size represented by x times 512 bytes. For example, PacketSize=6 means to set the packet size to 6 * 512 bytes (3072 bytes).To take advantage of this connection attribute, you must configure the Sybase server for a maximum network packet size greater than or equal to the value you specified for PacketSize. For example:sp_configure "maximum network packet size", 5120reconfigureRestart Sybase ServerNOTE: The ODBC specification specifies a connect option, SQL_PACKET_SIZE, that offers this same functionality. To avoid conflicts with applications that may set both the connection string attribute and the ODBC connect option, they have been defined as mutually exclusive. If PacketSize is specified, you will receive a message "Driver Not Capable" if you attempt to call SQL_PACKET_SIZE. If you do not set PacketSize, then application calls to SQL_PACKET_SIZE are accepted by the driver. Password (PWD) A case-sensitive password. PasswordEncryption (PE) Password Encryption={0 | 1}. A value that determines whether password encryption can be performed from the ODBC driver to the server. When set to 0, password encryption is disabled. When set to 1, password encryption is enabled.The initial default is 0. RaiseErrorPosition
Behavior (REPB) RaiseErrorPositionBehavior={0 | 1}. Specifies when the error is returned and where the cursor is positioned when raiserror is encountered.When set to 0 (the initial default), raiserror is handled separately from surrounding statements. The error is returned when raiserror is processed via SQLExecute, SQLExecDirect, or SQLMoreResults. The result set is empty.When set to 1 (MS compatible), raiserror is handled with the next statement. The error is returned when the next statement is processed; the cursor is positioned on the first row of subsequent result set. This could result in multiple raiserrors being returned on a single execute. SelectMethod (SM) SelectMethod={0 | 1}. Determines whether database cursors are used for Select statements.When set to 0 (the initial default), database cursors are used. In some cases performance degradation can occur when performing large numbers of sequential Select statements because of the amount of overhead associated with creating database cursors.When set to 1, Select statements are run directly without using database cursors, and the data source is limited to one active statement. SybaseLDAPURL (SLURL) Defines the Sybase LDAP URL that specifies the search operation that will be used to retrieve information from an LDAP directory. This URL includes host, port, database, distinguished name, and password. The format of this LDAP URL must adhere to RFC 2255.This attribute is valid only if the data source you are using for your connection is configured to use LDAP or you have "UseSybaseLDAPSchema (USLDAP)" set to 1 in your connection string. SybaseServerName (SSN) Defines the unique identifier for the LDAP directory entry where connection information is defined.This attribute is valid only if the data source you are using for your connection is configured to use LDAP or you have "UseSybaseLDAPSchema (USLDAP)" set to 1 in your connection string. TightlyCoupled
DistributedTransactions (TCDT)
TightlyCoupledDistributedTransactions={0 | 1}. Determines whether the driver uses tightly coupled distributed transactions when connected to an Sybase version 12 or higher database. When set to 1 (the initial default), the driver uses this type of transaction and multiple connections within the same distributed transaction do not obey each other’s locks.When set to 0, the overall performance of the driver is better, but multiple connections within the same distributed transaction may hang each other because the connections do not obey each other’s locks.This attribute is valid only when the driver is enlisted in a distributed transaction or when it is connected to a Sybase version 12 or higher database. Otherwise, this attribute is ignored. TrustedRootsFileName (TRFN) Specifies the location and name of the trusted roots file used for the SSL connection.A trusted roots file contains a list of known and trusted CAs (certificate authorities). This file is similar in format to a certificate file, except it contains certificates for CAs known to the entity (client applications, servers, etc.). This file is maintained using a standard ASCII text editor.If you are using an SSL connection, you must specify the name of a trusted roots file. To specify the use of an SSL connection in a connection string, you must set "UseSSL (USSL)" to 1. UseLDAPHAFailoverServer (ULDAPHA) UseLDAPHAFailoverServer={0 | 1}. Determines whether the driver uses the High Availability (HA) Failover server specified in the sybaseHAServernam attribute in the LDAP directory entry in the event of a connection loss.When set to 0 (the initial default), the driver does not use the HA Failover server specified on the LDAP server. This attribute is valid only if you are connecting to a Sybase version 12 or higher server that has the High Availability Failover feature enabled. UseSybaseLDAPSchema (USLDAP) UseSybaseLDAPSchema={0 | 1}. Determines whether the driver uses an LDAP directory entry to retrieve connection information.When set to 0 (the initial default), the driver does not use an LDAP directory entry to retrieve connection information; instead, the driver uses a data source to retrieve connection information.When set to 1, you must specify values for "SybaseLDAPURL (SLURL)" and "SybaseServerName (SSN)" in the data source you are using for connection. These attributes define the location of the LDAP server and the LDAP directory entry where the connection information is defined.See "Using LDAP" for information about the implementation of LDAP in the Sybase Wire Protocol driver. UseSSL (USSL) UseSSL={0 | 1}. Determines whether the driver uses a secure socket layer (SSL) connection. SSL is an industry standard for sending encrypted data over client-to-server and server-to-server connections. Connect ODBC supports the IETF TLS (Transport Layer Security) 1.0 standard.When set to 0 (the initial default), the driver does not use an SSL connection. If you are using an SSL connection, you must specify the name of a trusted roots file (see "TrustedRootsFileName (TRFN)").When set to 1, the driver uses an SSL connection IF you are using TCP/IP as the network protocol. WorkstationID (WKID) The workstation ID used by the client.